package LambdaDemo;


import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.Callable;
import java.util.function.Consumer;
import java.util.function.Function;

public class LambdaDemo {

    public static String toLowCase(String a){
        return  a.toLowerCase(Locale.ROOT);
    }

    public static  String toUpperCase(String s){
        return "552";
    }
    public static void main(String[] args) {

        List<String> list = Arrays.asList("java", "scala", "python");
        Collections.sort(list,(a,b)->a.length()-b.length());
        list.forEach(System.out::println);

        System.out.println((char)77);
        Callable<Integer> c=()->1;
        try {
            System.out.println(c.call());
        } catch (Exception e) {
            e.printStackTrace();
        }

        Function<String, String> f1=str->str.toLowerCase(Locale.ROOT);
        Function<String,String> f2=LambdaDemo::toLowCase;
        Function<String, String> f3=LambdaDemo::toUpperCase;
        System.out.println(f2.apply("RYT"));

        Consumer<Too> consumer=Too::foo;
        Consumer<Integer> consumer1=Too::new;
        consumer.accept(new Too(1));
        consumer1.accept(10);
    }
}

class Too{
    public int a;
    public Too(int a){
        System.out.println("a="+a);
        this.a=a;
    }
    public void foo(){
        System.out.println(a);
    }

    public void foo1(int a){
        System.out.println("a"+a);
    }
}
